package com.example.lemoncommon.exception;


import com.example.lemoncommon.enums.ResultEnum;
import lombok.Getter;

@Getter
public class ServiceException extends RuntimeException{


	private static final long serialVersionUID = 1L;

    // 错误code
    private String returnErrCode;

    // 错误message
    private String returnErrMsg;

    /**
     * 构造函数
     *
     * @param errCode
     * @param errMsg
     */
    public ServiceException(String errCode, String errMsg) {
        returnErrCode = errCode;
        returnErrMsg = errMsg;
    }

    public ServiceException(String message, Throwable cause) {
        super(message, cause);
    }

    public ServiceException(ResultEnum resultEnum) {
        super(resultEnum.getMessage());
        this.returnErrCode = resultEnum.getCode();
    }

    public ServiceException(String message) {
        super(message);
        this.returnErrCode = "400";
        this.returnErrMsg = message;
    }

}
